package itheima.d07_proxy_quickstart;

public class DogService {

    /**
        方式一：在需要性能统计的方法中，记录开始时间，记录结束时间，计算耗时
               缺点1：代码侵入性高，修改源代码
               缺点2：代码冗余度高，繁琐编码效率低
        方式二：动态代理实现
     */
    public void addDog(){
        //long start = System.currentTimeMillis();
        System.out.println("添加狗");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //long end = System.currentTimeMillis();
        //System.out.println("耗时：" + (end - start));
    }

    public void deleteDog(){
        //long start = System.currentTimeMillis();
        System.out.println("删除狗");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //long end = System.currentTimeMillis();
        //System.out.println("耗时：" + (end - start));
    }

    public void updateDog(){
        //long start = System.currentTimeMillis();
        System.out.println("更新狗");
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //long end = System.currentTimeMillis();
        //System.out.println("耗时：" + (end - start));
    }

    public void selectDog(){
        //long start = System.currentTimeMillis();
        System.out.println("查询狗");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //long end = System.currentTimeMillis();
        //System.out.println("耗时：" + (end - start));
    }

}


